package com.haoze.nurse.utils;

import org.apache.commons.lang3.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class HttpContextUtils {
	public static HttpServletRequest getHttpServletRequest() {
		return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
	}
	public static String getHeader(String headerName) {
		if (StringUtils.isEmpty(headerName)) {
			return "";
		}
		return getHttpServletRequest().getHeader(headerName);
	}

	public static String getUserId() {
		return getHttpServletRequest().getHeader("zuul_id");
	}

	public static String getUserPhone() {
		return getHttpServletRequest().getHeader("zuul_account");
	}

	public static String getHospital() {
		return getHttpServletRequest().getHeader("zuul_hospital_Id");
	}
}
